/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.registry;

import picounit.Registry;
import picounit.features.classloader.ClassReloader;

public class DefaultRegistryFactory implements RegistryFactory {
	private RegistryEntry initialEntries;
	private final ClassReloader classReloader;

	public DefaultRegistryFactory(RegistryEntry initialEntries, ClassReloader classReloader) {
		this.initialEntries = initialEntries;
		this.classReloader = classReloader;
	}

	public RegistryImpl create() {
		RegistryImpl registry = new RegistryImpl(classReloader);

		initialEntries.registerWith(registry);

		registry.register(Registry.class, registry);
		registry.register(Resolver.class, registry);

		return registry;
	}
}
